function Personal() {
}

Personal.init = function () {

}
function edit() {
    if(!validateForm()) return false;
    let postdata = {
        enterpriseId:$("#enterpriseId").val(),
        phone:$("#phone").val(),
    }
    $.ajax({
        url: '/slaughter/edit',
        type: "post",
        data: JSON.stringify(postdata),
        contentType: "application/json",
        dataType: "json",
        success: function (data) {
            if (data.code === "200") {
                swal("操作成功!", "请继续操作", "success");
            } else {
                swal("操作失败!", "请重试", "error");
            }
        }
    });
}
jQuery.validator.addMethod("isPhone", function(value, element) {
    var phone = $('#phone').val();
    if(phone!=''){
        var reg01 = /^(0|86|17951)?(13[0-9]|15[012356789]|17[01678]|18[0-9]|14[57])[0-9]{8}$/;
        var reg02 = /^(0[0-9]{2,3}\-)([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/;
        if(!reg01.test(phone) && !reg02.test(phone)){
            return false
        }
    }
    return true;
}, "(请输入正确的联系方式)");

function validateForm() {
    //validate方法参数可选
    return $("#myformdata").validate({
        rules: {
            phone: {
                required: true,//必填
                minlength: 1, //最少1个字符
                isPhone:true,
            },
        },
        //错误信息提示
        messages: {
            phone: {
                required: "(必填)",
                minlength: "最少1位",
                isPhone:"(请输入正确的联系方式)"
            },
        },
    }).form();
}